<script lang="ts">
  import Vue from 'vue'
  import * as auth from '@/utils/auth'
  import config from '@/config/index'
  import { mapActions } from 'vuex'
  const systemInfo = uni.getSystemInfoSync()
  export default Vue.extend({
    mpType: 'app',
    globalData: {
      isReload: false, //是否需要重新加载页面
      blockApi: false, //是否阻塞api 请求
      safeBottom: 0,
      token: '',
      uId: '',
      registerActivityId: '',
      account: '',
      password: '',
      userInfo: null,
      debug: false
    },

    onLaunch() {
      Vue.prototype.systemInfo = systemInfo
      //#ifndef H5
      this.initApp()
      // auth.handelBlockApi(this)
      //#endif
      auth.setDataDictionary() // 本地数据字典
      auth.safeBottom(this)
      auth.judgeLocation()
      auth.setTabBarItem()
      auth.toGetAreaInfo(true)
    },
    onError(err) {
      if (config.NODE_ENV !== 'production') {
        console.log(err)
      }
      this.handleSubmitError(err)
    },
    methods: {
      ...mapActions(['initApp', 'errorLog']),
      handleSubmitError(error) {
        const routes = getCurrentPages()
        const router = routes[routes.length - 1]
        this.errorLog({
          device: JSON.stringify(systemInfo),
          content: `[客户端错误] ${error.toString()}`,
          route: router.route
        })
      }
    }
  })
</script>

<style lang="scss">
  @import './sass/index.scss';
  /* 每个页面公共css */
  // tab图标
  .uni-tabbar .uni-tabbar__icon {
    width: 40rpx !important;
    height: 40rpx !important;
  }

  uni-modal {
    z-index: 999999 !important;
  }
</style>
